package com.itheima.wemedia.controller;


import com.itheima.common.vo.ResultVo;
import com.itheima.wemedia.pojo.WmUser;
import com.itheima.wemedia.service.WmUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.DigestUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/login")
@Api(value = "LoginController",tags = "自媒体登录")
public class LoginController {

    @Autowired
    private WmUserService wmUserService;

    /**
     * 自媒体登陆功能
     * @return
     */
    @ApiOperation(value = "登录接口")
    @PostMapping("/in")
    public ResultVo loginCheck(@RequestBody Map<String ,String> loginParams){
        //1.调用service执行业务
            Map<String ,Object> result =  wmUserService.loginCheck(loginParams);
            return  ResultVo.ok(result);
    }

    public static void main(String[] args) {
        System.out.println(DigestUtils.md5DigestAsHex("admin123abc".getBytes()));
        System.out.println(DigestUtils.md5DigestAsHex("wangwu123abc".getBytes()));
    }
}
